﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
namespace DataAccess
{
    public class TruyXuatTimChuyenBay
    {
        ChuyenBay _cb = new ChuyenBay();

        public ChuyenBay cb
        {
            get { return _cb; }
            set { _cb = value; }
        }
        string sanBayDi;

        public string SanBayDi
        {
            get { return sanBayDi; }
            set { sanBayDi = value; }
        }
        string sanBayDen;

        public string SanBayDen
        {
            get { return sanBayDen; }
            set { sanBayDen = value; }
        }
        DateTime ngayVe;

        public DateTime NgayVe
        {
            get { return ngayVe; }
            set { ngayVe = value; }
        }
        public DataTable ThongTinChuyenBay()
        {
            DataProvider dp = new DataProvider();
            dp.KetNoi();
            string sql = "select * from CHUYENBAY where MaTuyenBay in (select MaTuyenBay from TUYENBAY where SanBayDi='" + SanBayDi + "' and SanBayDen='" + SanBayDen + "')";
            string sql4 = " and NgayDi=CONVERT(date, '" + cb.NgayDi + "', 101)";
            if (cb.NgayDi != DateTime.MinValue)
            {
                sql += sql4;
                
            }
         
            //sql = "select * from CHUYENBAY where MaTuyenBay in (select MaTuyenBay from TUYENBAY where SanBayDi='" + SanBayDi + "' and SanBayDen='" + SanBayDen + "') and NgayDi=CONVERT(date, '"+cb.NgayDi+"', 101)";
            return dp.ExcuteQuery(sql);

           // dp.NgatKetNoi();
        }
        public DataTable ThongTinChuyenBayVe()
        {
            DataProvider dp = new DataProvider();
            dp.KetNoi();
            string sql = "select * from CHUYENBAY where MaTuyenBay in (select MaTuyenBay from TUYENBAY where SanBayDi='" + SanBayDen + "' and SanBayDen='" + SanBayDi + "')";
            string sql5 = "and NgayDi=CONVERT(date, '" + NgayVe + "', 101)";
            if (NgayVe != DateTime.MinValue)
            {
                sql += sql5;
            }
           // sql = "select * from CHUYENBAY where MaTuyenBay in (select MaTuyenBay from TUYENBAY where SanBayDi='" + SanBayDen + "' and SanBayDen='" + SanBayDi + "') and NgayDi=CONVERT(date, '" + NgayVe + "', 101)";
            return dp.ExcuteQuery(sql);
            //dp.NgatKetNoi();
        }
    }
}
